<?php
/**
 * Created by PhpStorm.
 * User: zmit
 * Date: 8/9/17
 * Time: 5:53 PM
 */
namespace AdminBundle\Controller;


class AccountController extends AdminController
{
    /*
     * 普通管理员帐号列表
     */
    public function accountIndexAction()
    {
        if(!$this->get("session")->get("admin_id")){

            return $this->render('AdminBundle:Auth:login.html.twig');
        }

        $data = $this->getApiData("ApiBundle:Public:getDistrict");
        return $this->render("AdminBundle:Account:index.html.twig",array("data"=>$data));
    }


    /*
     * 编辑/添加 普通管理员帐号
     */
    public function editAccountAction($id)
    {
        if(!$this->get("session")->get("admin_id")){

            return $this->render('AdminBundle:Auth:login.html.twig');
        }

        $conn = $this->get("database_connection");
        $data = $conn->fetchAssoc("SELECT * FROM admin WHERE id = '". $id ."'");

        if(empty($id)){

            $super_admin_id = $this->get("session")->get("admin_id");
            $super_district_id = $conn->fetchAssoc("SELECT * FROM admin WHERE id = '". $super_admin_id ."'");
            $data = array("id" => 0,"super_district_id"=>$super_district_id['district_id']);
        }
        return $this->render("AdminBundle:Account:editAccount.html.twig",array("data"=>$data));
    }


    /*
     * 科技联络人审核
     */
    public function examineAccountAction()
    {
        if(!$this->get("session")->get("admin_id")){

            return $this->render('AdminBundle:Auth:login.html.twig');
        }
        return $this->render("AdminBundle:Account:examineAccount.html.twig");
    }
}